package org.electrode.common;

import edu.wpi.first.wpilibj.networktables.NetworkTable;
import edu.wpi.first.wpilibj.tables.ITable;

public class NetworkTableVariable implements Variable {
	private final ITable table;
	private final String name;

	public NetworkTableVariable(String name, double inital) {
		this(NetworkTable.getTable("SmartDashboard"), name, inital);
	}

	public NetworkTableVariable(ITable table, String name, double initial) {
		this.table = table;
		this.name = name.intern();
		set(initial);
	}

	public double get() {
		return table.getNumber(name);
	}

	public void set(double value) {
		table.putNumber(name, value);
	}
}